package com.ssm.user.designPattern.filterPattern;

import java.util.ArrayList;
import java.util.List;

public class GenderFilter implements Filter{

    private GenderEnum genderEnum;

    public GenderFilter(GenderEnum genderEnum) {
        // 在构造方法时指定性别
        this.genderEnum = genderEnum;
    }
    @Override
    public List<People> doFilter(List<People> peopleList) {
        List<People> result = new ArrayList<>();
        for (People people : peopleList) {
            if (this.genderEnum.equals(people.getGenderEnum())) {
                result.add(people);
            }
        }
        return result;
    }
}
